package Reminder.domain;

import org.apache.commons.codec.digest.DigestUtils;
import Reminder.view.GlobalConfig;

public class Encryption {
    public static String md5(String text) throws Exception {
        String encodeStr= DigestUtils.md5Hex(text + GlobalConfig.MD5_KEY);
        System.out.println("MD5加密后的字符串为:encodeStr="+encodeStr);
        return encodeStr;
    }
    public static boolean verify(String text, String key, String md5) throws Exception {
        //根据传入的密钥进行验证
        String md5Text = md5(text + GlobalConfig.MD5_KEY);
        if(md5Text.equalsIgnoreCase(md5))
        {
            System.out.println("MD5验证通过");
            return true;
        }

        return false;
    }
}
